package com.njxzc.demo.controller.before;

import com.njxzc.demo.common.http.ResponseResult;
import com.njxzc.demo.common.security.anno.AuthIgrone;
import com.njxzc.demo.entity.CartEntity;
import com.njxzc.demo.service.admin.GoodsService;
import com.njxzc.demo.service.before.CartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("api/beofre/cart")
public class CartController {
    @Autowired
    private CartService cartService;

    @Autowired
    private GoodsService goodsService;

    /**
     * 注意：！！！！！！！！
     * 下面调用的是goodsService里的myCartGoods方法。
     * @param cartEntity
     * @return
     */
    @AuthIgrone
    @PostMapping("/myCart")
    public ResponseResult<List<Map<String, Object>>> myCartGoods(@RequestBody CartEntity cartEntity){
        return goodsService.myCartGoods(cartEntity);
    }

    @AuthIgrone
    @PostMapping("/addCart")
    public ResponseResult<Map<String, Object>> addCart(@RequestBody CartEntity cartEntity){
        return cartService.addCart(cartEntity);
    }

    @AuthIgrone
    @PostMapping("/bupDateCart")
    public ResponseResult<Map<String, Object>> bupDateCart(@RequestBody CartEntity cartEntity){
        return cartService.bupDateCart(cartEntity);
    }

    @AuthIgrone
    @PostMapping("/clearCart")
    public ResponseResult<Map<String, Object>> clearCart(@RequestBody CartEntity cartEntity){
        return cartService.clearCart(cartEntity);
    }

    @AuthIgrone
    @PostMapping("/removeCart")
    public ResponseResult<Map<String, Object>> removeCart(@RequestBody CartEntity cartEntity){
        return cartService.removeCart(cartEntity);
    }

}
